#include "Epoller.h"

using namespace devem;

void Epoller::Wait(std::vector<Channel*>* active, int flag) {
    int ret = epoll_wait(epfd_, evs, EPOLL_WAIT_NUM, 0);
    if (ret < 0) {
        LOG_WARN("epoll wait error.");
        return;
    }
    for (int i = 0; i < ret; i++) {
        auto it = channels_.find(evs[i].data.fd);
        if (it == channels_.end()) {
            return;
        }
        it->second->SetRevents(evs[i].events);
        active->push_back(it->second);
    }
}